package org.blog.model;

import org.blog.util.StringHelper;

public class ModelCatalog extends BaseModel implements ValidateModel{
//	private Integer id;// 8
//	private String username;// 20
	private String catName;// 9
	private Long createTime;// 13
	private Long actionTime;// 13
	private int action;// 状态 1：添加，2：修改，3：删除

//	public String getUsername() {
//		return username;
//	}
//
//	public void setUsername(String username) {
//		this.username = username;
//	}

	public String getCatName() {
		return catName;
	}

	public void setCatName(String catName) {
		this.catName = catName;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	public Long getActionTime() {
		return actionTime;
	}

	public void setActionTime(Long actionTime) {
		this.actionTime = actionTime;
	}

	public int getAction() {
		return action;
	}

	public void setAction(int action) {
		this.action = action;
	}

//	public Integer getId() {
//		return id;
//	}
//
//	public void setId(Integer id) {
//		this.id = id;
//	}

	@Override
	public boolean validate(ActionType type) {

		if (ActionType.ADD.equals(type)) {
			if (StringHelper.isEmptyTrim(getCatName())) {
				return false;
			}
		} else if (ActionType.MODIFY.equals(type)) { 
			if (StringHelper.isEmptyTrim(getCatName()) || id == null) {
				return false;
			}
		} else if (ActionType.DELETE.equals(type)) {
			if (  getId() == null) {
				return false;
			}
		} else if (ActionType.GET.equals(type)) {
			if (  getId() == null) {
				return false;
			}
		}
		return true;
	}

}
